<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box,
        .box2 {
            width: 400px;
            height: 400px;
            background-color: green;
        }

        .box .inner-box,
        .box2 .inner-box2 {
            width: 200px;
            height: 200px;
            background-color: pink;
        }

        .box2 {
            background-color: lightblue;
        }

        .box2 .inner-box2 {
            background-color: orange;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="inner-box">

        </div>
    </div>
    <div class="box2">
        <div class="inner-box2">

        </div>
    </div>
    <script>
        var box = document.querySelector('.box');
        var innerBox = document.querySelector('.inner-box');
        box.onclick = function(){
            console.log('box...');
        }
        innerBox.onclick = function(){
            console.log('innerbox...');
        }
        
        var box2 = document.querySelector('.box2');
        var innerBox2 = document.querySelector('.inner-box2');
        box2.addEventListener('click', function () {
            console.log('box2');
        }, true)
        // 设置第三个数，true为捕获， 默认为false冒泡  控制事件的执行循序
        innerBox2.addEventListener('click', function () {
            console.log('inner-box2');
        })
    </script>
</body>

</html>